package com.ruoyi.web.controller.wechat;

import com.ruoyi.common.constant.HfConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.web.controller.wechat.request.NotificationRequest;
import com.ruoyi.web.controller.wechat.request.TransImageRequest;
import com.ruoyi.web.controller.wechat.response.AuthResponse;
import com.ruoyi.web.controller.wechat.response.LocationResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO
 *
 * @author chenchuan2
 * @date 2023-03-06 13:44:06
 */
@RestController
@RequestMapping("/wechat-api/trans")
@Slf4j
public class TransController extends AuthController {

    @GetMapping("/location")
    public R<LocationResponse> location() {
        String openId = getOpenId();
        LocationResponse response = new LocationResponse();
        response.setLongitude(HfConstants.JCF.getLongitude() + "");
        response.setLatitude(HfConstants.JCF.getLatitude() + "");
        response.setLocationName(HfConstants.JCF.getLocationName());
        return R.ok(response);
    }

    @PostMapping("/shareLocation")
    public R<Boolean> shareLocation(@RequestBody TransImageRequest request) {
        //判断用户是否有权限

        //查询地址名称

        //缓存用户经纬度

        return R.ok();
    }

    @PostMapping("/createNotification")
    public R<Boolean> createNotification(@Validated @RequestBody NotificationRequest request) {
        return R.ok();
    }

    @PostMapping("/notification")
    public R<List<String>> notification() {
        List<String> result = Lists.newArrayList();
        result.add("【7点半】班车不发车");
        return R.ok(result);
    }

    @GetMapping("/auth")
    public R<AuthResponse> auth() {
        AuthResponse response = new AuthResponse();
        response.setTransAuth(true);
        return R.ok(response);
    }

}
